<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>closure闭包</title>
</head>
<body>
  <script>
    // Math.pow(4, 2)
    // Math.pow(5, 2)

    // 生成求平方立方函数

    // 通过chrome断点调试可以去查看调用栈，变量对象及闭包的详细信息

    function makePower (power) {
      return function (num) {
        return Math.pow(num, power)
      }
    }

    const power2 = makePower(2)
    const power3 = makePower(3)

    console.log(power2(2))
    console.log(power3(2))
  </script>
</body>
</html>
